package io.gitee.bluemiaomiao.dataanalyzebackend.service.impl;

import io.gitee.bluemiaomiao.dataanalyzebackend.repos.SaleCountMapper;
import io.gitee.bluemiaomiao.dataanalyzebackend.util.RepoType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;

/**
 * @author Administrator
 */
//@Component
//public class ExcelServiceImpl implements ExcelService {
//
//    private Logger log = LoggerFactory.getLogger(getClass());
//
//    @Autowired
//    private SaleCountMapper saleCountMapper;
//
//    @Override
//    public void convertExcelToSql(InputStream stream, boolean isOldVersion, int workbookType,int TableType) throws IOException {
//        Workbook workbook = null;
//
//        // 根据不同的Excel版本构造表格对象
//        if (isOldVersion) {
//            workbook = new HSSFWorkbook(stream);
//        } else {
//            workbook = new XSSFWorkbook(stream);
//        }
//
//        // 判断读取什么类型的Excel
//        if (workbookType == RepoType.SALE_COUNT) {
//            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
//            String currentDate = df.format(new Date());
//            if(TableType == 1)
//            {
//                Vector<SaleItems> vector = new Vector<>();
//            }
//            if(TableType == 2)
//            {
//                Vector<SaleItems> vector = new Vector<>();
//            }
//            if(TableType == 3)
//            {
//                Vector<SaleItems> vector = new Vector<>();
//            }
//            if(TableType == 4)
//            {
//                Vector<SaleItems> vector = new Vector<>();
//            }
//            if(TableType == 5)
//            {
//                Vector<SaleItems> vector = new Vector<>();
//            }
//
//
//            Sheet sheet = workbook.getSheetAt(0);
//            int firstRowNum = sheet.getFirstRowNum();
//            int lastRowNum = sheet.getLastRowNum();
//            for (int count = firstRowNum + 3; count < lastRowNum; count++) {
//                Row row = sheet.getRow(count);
//                if (row != null) {
//                    // 设置单元格类型
//                    int maxCol = row.getLastCellNum();
//                    for (int col = row.getFirstCellNum(); col < maxCol; col++) {
//                        row.getCell(col).setCellType(CellType.STRING);
//                    }
//
//                    // 读取数据
//
//                    vector.add();
//                }
//            }
//            saleCountMapper.save(vector);
//        }
//    }
//}
